import { IFeidaoAiBrowserComponent } from '@feidao/web/interfaces';
import excel_json from "../../atom-web/excel-json";
import nodejs from '@feidao/web/atom/browser/msg/nodejs';
import { send_msg as url } from "../../atom-web/config";

export default async function a001(fd: IFeidaoAiBrowserComponent, ...args: any[]) {
	// todo
	const input = fd.data.node.querySelector<HTMLInputElement>('[data-feidao-id="file-id"]');
	const file = input.files[0];
	const reader = new FileReader();
	reader.onload = async (e) => {
		const str = excel_json(reader.result as any);
		const d = await nodejs(url, 'import-excel', { str }, false, false);
		console.log(d);
	};
	reader.readAsArrayBuffer(file);
}
